package com.sktlab.bizconfmobile.model;

import org.apache.mina.core.session.IoSession;

import com.sktlab.bizconfmobile.mina.MinaMsg;
import com.sktlab.bizconfmobile.mina.MinaUtil;
import com.sktlab.bizconfmobile.model.manager.ConferenceManager;

public class BVSession extends BaseBusinessSession {

	@Override
	public void create(IoSession session, LSSession ls) {
		
		MinaMsg msg = new MinaMsg();
		
		msg.clearMsgData();
		msg.setSsnId(ls.getId());
		msg.setSeq(ls.getSeqNum());
		msg.setMsgId(MinaUtil.MSG_LS_CS);		
		msg.appendMsgData(MinaUtil.MSG_BV);
		
		session.write(msg.toString());
	}
	
	/**
	 * Request a list of active conferences in current bridge This method just
	 * send a request message to server,the List data should be handle in
	 * ClientMinaHandler's msg receive method. for further use, the list should
	 * be stored in ConferenceManager
	 */
	public void requestActiveConfList(IoSession session) {

		MinaMsg msg = new MinaMsg();

		msg.clearMsgData();
		msg.setSsnId(getId());
		msg.setSeq(getSeqNum());
		msg.setMsgId(MinaUtil.MSG_ACTIVE_CONF_LIST);

		session.write(msg.toString());

		ConfControl.notifyObj();
	}
	
	public void close(IoSession session, LSSession ls) {
		
		MinaMsg msg = new MinaMsg();
		
		msg.clearMsgData();	
		msg.setSsnId(ls.getId());
		msg.setSeq(ls.getSeqNum());
		msg.setMsgId(MinaUtil.MSG_LS_DS);
		msg.appendMsgData(getId());			
		session.write(msg.toString());		
	}
}
